import React, { Component } from 'react';
import { Card } from 'antd';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import routesConfig from '../../../config/router.config';
import { connect } from 'dva';

@connect(({ menu }) => ({
	menu,
}))

class ContainerWrapper extends Component {

  state = {
		title: ''
	}

	componentDidMount(){
		const { menu } = this.props;
		const urlParams = new URL(window.location.href);
		let title = menu.breadcrumbNameMap && menu.breadcrumbNameMap[urlParams.pathname].name || ''
		this.setState({title})
	}
	render() {
		const {title} = this.state;

		return (
				<PageHeaderWrapper title = {title}>
					<Card bordered={false}>
						{this.props.children}
					</Card>
				</PageHeaderWrapper>
		)
	}
}

export default  ContainerWrapper